<template>
    <div class="search-box">
        <advanceSearch />
            <a-spin :spinning="spinning" size="large" tip="Loading...">
            <div class="main-box">
                <div class="left-box">
                    <div class="tit">出版年</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetYearList" :key="index" :class="facetYear==item.name?'cur':''" v-show="showAllYear||index<6" @click="filterChange('facetYear',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetYearList" :key="index" :class="facetYearFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllYear||index<6" @click="filterChange('facetYear',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetYearList.length>=6">
                            <a href="javascript:" @click="showAll('showAllYear')"><a-icon :type="showAllYear?'caret-up':'caret-down'"></a-icon>{{showAllYear?'收起':'全部显示'}}</a>
                        </div>
                    </div>
                    <div class="tit">出版地</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetPlaceList" :key="index" :class="facetPlace==item.name?'cur':''" v-show="showAllPlace||index<6" @click="filterChange('facetPlace',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetPlaceList" :key="index" :class="facetPlaceFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllPlace||index<6" @click="filterChange('facetPlace',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetPlaceList.length>=6">
                            <a href="javascript:" @click="showAll('showAllPlace')"><a-icon :type="showAllPlace?'caret-up':'caret-down'"></a-icon>{{showAllPlace?'收起':'全部显示'}}</a>
                        </div>
                    </div>
                    <div class="tit">出版社</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetPublisherList" :key="index" :class="facetPublisher==item.name?'cur':''" v-show="showAllPublisher||index<6" @click="filterChange('facetPublisher',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetPublisherList" :key="index" :class="facetPublisherFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllPublisher||index<6" @click="filterChange('facetPublisher',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetPublisherList.length>=6">
                            <a href="javascript:" @click="showAll('showAllPublisher')"><a-icon :type="showAllPublisher?'caret-up':'caret-down'"></a-icon>{{showAllPublisher?'收起':'全部显示'}}</a>
                        </div>
                    </div>

                    <div class="tit">图书分类</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetClassList" :key="index" :class="facetClass==item.name?'cur':''" v-show="showAllClass||index<6" @click="filterChange('facetClass',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetClassList" :key="index" :class="facetClassFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllClass||index<6" @click="filterChange('facetClass',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetClassList.length>=6">
                            <a href="javascript:" @click="showAll('showAllClass')"><a-icon :type="showAllClass?'caret-up':'caret-down'"></a-icon>{{showAllClass?'收起':'全部显示'}}</a>
                        </div>
                    </div>

                    <div class="tit">责任者</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetPersonList" :key="index" :class="facetPerson==item.name?'cur':''" v-show="showAllPerson||index<6" @click="filterChange('facetPerson',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetPersonList" :key="index" :class="facetPersonFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllPerson||index<6" @click="filterChange('facetPerson',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetPersonList.length>=6">
                            <a href="javascript:" @click="showAll('showAllPerson')"><a-icon :type="showAllPerson?'caret-up':'caret-down'"></a-icon>{{showAllPerson?'收起':'全部显示'}}</a>
                        </div>
                    </div>
                    <div class="tit">主题词</div>
                    <div class="filter-box">
                        <ul>
                            <!-- <li v-for="(item,index) in facetKeywordList" :key="index" :class="facetKeyword==item.name?'cur':''" v-show="showAllKeyword||index<6" @click="filterChange('facetKeyword',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li> -->
                            <li v-for="(item,index) in facetKeywordList" :key="index" :class="facetKeywordFilterList.indexOf(item.name)>-1?'cur':''" v-show="showAllKeyword||index<6" @click="filterChange('facetKeyword',item.name,index)">{{item.name}}<span>( {{item.count}} )</span></li>
                        </ul>
                        <div class="show-all" v-if="facetKeywordList.length>=6">
                            <a href="javascript:" @click="showAll('showAllKeyword')"><a-icon :type="showAllKeyword?'caret-up':'caret-down'"></a-icon>{{showAllKeyword?'收起':'全部显示'}}</a>
                        </div>
                    </div>
                    <div class="tit">是否有全文</div>
                    <div class="filter-box">
                        <ul>
                            <li v-for="(item,index) in facetPdfCountList" :key="index" :class="facetPdfCountFilterList.indexOf(item.name)>-1?'cur':''" @click="filterChange('facetPdfCount',item.name,index)">{{item.name == "1" ? "内网有":item.name == "0" ? "外网有":"无"}}<span>( {{item.count}} )</span></li>
                        </ul>
                    </div>
                </div>
                <div class="right-content">
                    <resultList ref="result" :resultData="resultData" :rowCount="rowCount" :filters="filters" :sort.sync="sort" :disableSortScore="disableSortScore" @sortChange="normalSearch" />
                </div>
            </div>
            <div class="main-box">
                <a-pagination show-size-changer show-quick-jumper :current="pageth" :page-size="pageSize" :total="rowCount" :page-size-options="pageSizeOptions" @showSizeChange="onShowSizeChange" @change="onChange" />
            </div>
        </a-spin>
        <a-modal v-model="visibleUser" :closable="false" :keyboard="false" :maskClosable="false" width="20%" title="消息" @ok="login">
            <template slot="footer"><a-button key="submit" type="primary" @click="ConfirmError">确认</a-button></template>
            <p class="failure">获取用户信息出错，请联系管理员！</p>
        </a-modal>
        <a-modal v-model="visibleLook" :closable="false" :keyboard="false" :maskClosable="false" width="20%" title="消息" @ok="logout">
            <template slot="footer"><a-button key="submit" type="primary" @click="logout">确认</a-button></template>
            <p class="failure">您无权访问此站点！</p>
        </a-modal>
    </div>
</template>

<script>
    import axios from 'axios'
    import advanceSearch from '../../components/layout/advanceSearch'
    import resultList from '../../components/resultList'
    import { instanceSearch, reportQuery, accountAuthtication } from '../../api/urls';
    export default {
        components:{
            advanceSearch,
            resultList
        },

        data(){
            console.log(this.$route)
            return{
                visibleLook: false,
                visibleUser: false,
                typeList: ['all','title','person','place','publisher','theme','publication','start','end'],
                showAllYear: false,
                showAllPlace: false,
                showAllPublisher: false,
                showAllClass: false,
                showAllPerson: false,
                showAllKeyword: false,
                facetYearFilterList: [],
                facetPlaceFilterList: [],
                facetPublisherFilterList: [],
                facetClassFilterList: [],
                facetPersonFilterList: [],
                facetKeywordFilterList: [],
                facetPdfCountFilterList: [],
                facetYear: '',
                facetPlace: '',
                facetPublisher: '',
                facetClass: '',
                facetPerson: '',
                facetKeyword: '',
                facetPdfCount:'',
                facetYearList: [],
                facetPlaceList: [],
                facetPublisherList: [],
                facetClassList: [],
                facetPersonList: [],
                facetKeywordList: [],
                facetPdfCountList:[{"name":"有PDF","count":55},{"name":"无PDF","count":80}],
                spinning: true,
                params: {
                    all: this.$route.query.keywords || '',
                    title: '',
                    person: '',
                    place: '',
                    publisher: '',
                    theme: '',
                    publication: '',
                    start: '',
                    end: '',
                },
                resultData: [],
                rowCount: 0,
                sortScore: '', // 无:'' , 升序:'0' , 降序:'1'
                sortTitle: '1', // 无:'' , 升序:'0' , 降序:'1'
                sortPerson: '', // 无:'' , 升序:'0' , 降序:'1'
                sort: { field: "score", order: "asc" }, // score title person
                disableSortScore: false,
                filters: [],
                secondCdtn: '',
                secondList: [],
                // instanceDetail页面传过来的参数
                receivedTitle: this.$route.params.title,
                receivedPublisher: this.$route.params.publisher,
                receivedPublication: this.$route.params.publication,
                receivedTheme: this.$route.params.theme,
                // 检索埋点字段
                query: "",
                filterQueries: [],
                actionType: "", // 按钮检索/聚类检索
                pageth: 1,
                pageSize: 10, // 每页显示几条 
                pageSizeOptions: ['10', '20', '30', '40', '50'],
            }
        },

        created() {
            this.checkUser()
            this.checkKeywords()
            this.originSearch()
        },

        mounted() {
            
        },

        methods:{
            // 是否显示关键词相关度排序
            checkKeywords() {
                if (
                    this.params.all ||
                    this.params.title ||
                    this.params.person ||
                    this.params.place ||
                    this.params.publisher ||
                    this.params.theme ||
                    this.params.publication ||
                    this.secondCdtn
                ) {
                    this.sort.field = "score";
                    this.sort.order = "desc";
                    this.disableSortScore = false;
                } else {
                    this.sort.field = "title";
                    this.sort.order = "asc";
                    this.disableSortScore = true;
                }
            },
            // 原始检索
            originSearch() {
                this.spinning = true
                this.showAllYear = false
                this.showAllPlace = false
                this.showAllPublisher = false
                this.showAllClass = false
                this.showAllPerson = false
                this.showAllKeyword = false
                this.facetYearFilterList = []
                this.facetPlaceFilterList = []
                this.facetPublisherFilterList = []
                this.facetClassFilterList = []
                this.facetPersonFilterList = []
                this.facetKeywordFilterList = []
                this.facetPdfCountFilterList = []
                this.facetYear = ''
                this.facetPlace = ''
                this.facetPublisher = ''
                this.facetClass = ''
                this.facetPerson = ''
                this.facetKeyword = ''
                this.facetPdfCount = ''
                this.secondCdtn = ''
                this.secondList = []
                if(this.receivedTitle) {
                    this.params.title = this.receivedTitle
                }
                if(this.receivedPublisher) {
                    this.params.publisher = this.receivedPublisher
                }
                if(this.receivedPublication) {
                    this.params.publication = this.receivedPublication
                }
                if(this.receivedTheme) {
                    this.params.theme = this.receivedTheme
                }
                this.filters = []
                this.pageth = 1
                this.pageSize = 10
                this.addParamsFilter(this.params)
                this.checkKeywords()
                let opts = {
                    cdtn: [
                        // 全字段
                        {
                            logic: "and", 
                            field: "ALL", 
                            value: this.params.all||'', 
                            type: "0"
                        },
                        // 题名
                        {
                            logic: "and", 
                            field: "TM", 
                            value: this.params.title||'', 
                            type: "0"
                        },
                        // 作者
                        {
                            logic: "and", 
                            field: "ZRZ", 
                            value: this.params.person||'', 
                            type: "0"
                        },
                        // 出版地
                        {
                            logic: "and", 
                            field: "CBD", 
                            value: this.params.place||'', 
                            type: "0"
                        },
                        // 出版社
                        {
                            logic: "and", 
                            field: "CBJG", 
                            value: this.params.publisher||'', 
                            type: "0"
                        },
                        // 主题词
                        {
                            logic: "and", 
                            field: "ZTC", 
                            value: this.params.theme||'', 
                            type: "0"
                        },
                        // 发行制作机构
                        {
                            logic: "and", 
                            field: "FXJG", 
                            value: this.params.publication||'', 
                            type: "0"
                        },
                        // 起始年
                        {
                            logic: "and", 
                            field: "YEAR", 
                            value: this.params.start || (this.params.end ? "1800" : ""), 
                            type: "2"
                        },
                        // 结束年
                        {
                            logic: "and", 
                            field: "YEAR", 
                            value: this.params.end || (this.params.start ? "1999" : ""), 
                            type: "3"
                        },
                    ],
                    sorts: {
                        field: this.sort.field,
                        type: this.sort.order === "asc" ? "0" : "1",
                    },
                    pager: {
                        pageth: 1,
                        pageSize: 10
                    }
                }
                this.getResultData(opts)

                // 检索埋点（按钮检索） START
                this.query = ""
                this.filterQueries = []
                this.actionType = "按钮检索"
                if(this.params.all) {
                    this.query += "AND ALL:'"+this.params.all+"' "
                }
                if(this.params.title) {
                    this.query += "AND TM:'"+this.params.title+"' "
                }
                if(this.params.person) {
                    this.query += "AND ZRZ:'"+this.params.person+"' "
                }
                if(this.params.place) {
                    this.query += "AND CBD:'"+this.params.place+"' "
                }
                if(this.params.publisher) {
                    this.query += "AND CBJG:'"+this.params.publisher+"' "
                }
                if(this.params.theme) {
                    this.query += "AND ZTC:'"+this.params.theme+"' "
                }
                if(this.params.publication) {
                    this.query += "AND FXJG:'"+this.params.publication+"' "
                }
                if(this.params.start) {
                    this.query += "AND YEAR:['"+this.params.start+"' TO *] "
                }
                if(this.params.end) {
                    this.query += "AND YEAR:[* TO '"+this.params.freetext+"'] "
                }
                // this.buryingPoint()
                // 检索埋点（按钮检索） END
            },

            normalSearch() {
                this.spinning = true
                this.addParamsFilter(this.params)
                let opts = {
                    cdtn: [
                        // 全字段
                        {
                            logic: "and", 
                            field: "ALL", 
                            value: this.params.all||'', 
                            type: "0"
                        },
                        // 题名
                        {
                            logic: "and", 
                            field: "TM", 
                            value: this.params.title||'', 
                            type: "0"
                        },
                        // 作者
                        {
                            logic: "and", 
                            field: "ZRZ", 
                            value: this.params.person||'', 
                            type: "0"
                        },
                        // 出版地
                        {
                            logic: "and", 
                            field: "CBD", 
                            value: this.params.place||'', 
                            type: "0"
                        },
                        // 出版社
                        {
                            logic: "and", 
                            field: "CBJG", 
                            value: this.params.publisher||'', 
                            type: "0"
                        },
                        // 主题词
                        {
                            logic: "and", 
                            field: "ZTC", 
                            value: this.params.theme||'', 
                            type: "0"
                        },
                        // 发行制作机构
                        {
                            logic: "and", 
                            field: "FXJG", 
                            value: this.params.publication||'', 
                            type: "0"
                        },
                        // 起始年
                        {
                            logic: "and", 
                            field: "YEAR", 
                            value: this.params.start||'', 
                            type: "2"
                        },
                        // 结束年
                        {
                            logic: "and", 
                            field: "YEAR", 
                            value: this.params.end||'', 
                            type: "3"
                        },
                        // 分面出版年
                        {
                            logic: this.facetYear=='其他 '?'not':'and', 
                            field: "FACET_YEAR", 
                            value: this.facetYear||'', 
                            type: this.facetYear=='其他 '?'4':'1'
                        },
                        // 分面出版地
                        {
                            logic: this.facetPlace=='其他 '?'not':'and', 
                            field: "FACET_PLACE", 
                            value: this.facetPlace||'', 
                            type: this.facetPlace=='其他 '?'4':'1'
                        },
                        // 分面出版社
                        {
                            logic: this.facetPublisher=='其他 '?'not':'and',  
                            field: "FACET_PUBLISHER", 
                            value: this.facetPublisher||'', 
                            type: this.facetPublisher=='其他 '?'4':'1'
                        },
                        // 分面图书分类
                        {
                            logic: this.facetClass=='其他 '?'not':'and',  
                            field: "FACET_CLASSES", 
                            value: this.facetClass||'', 
                            type: this.facetClass=='其他 '?'4':'1'
                        },
                        // 分面作者
                        {
                            logic: this.facetPerson=='其他 '?'not':'and',  
                            field: "FACET_PERSON", 
                            value: this.facetPerson||'', 
                            type: this.facetPerson=='其他 '?'4':'1'
                        },
                        // 分面主题词
                        {
                            logic: this.facetKeyword=='其他 '?'not':'and',  
                            field: "FACET_SUBJECT", 
                            value: this.facetKeyword||'', 
                            type: this.facetKeyword=='其他 '?'4':'1'
                        },
                        // 是否有全文
                        {
                            logic: this.facetPdfCount=='其他 '?'not':'and',  
                            field: "FACET_ACCESSLEVEL", 
                            value: this.facetPdfCount||'', 
                            type: this.facetPdfCount=='其他 '?'4':'1'
                        }
                    ],
                    // 二次检索
                    secondCdtn: this.secondCdtn,
                    // 排序
                    sorts: {
                        field: this.sort.field,
                        type: this.sort.order === "asc" ? "0" : "1",
                    },
                    // 页码
                    pager: {
                        pageth: this.pageth,
                        pageSize: this.pageSize
                    }
                }
                this.getResultData(opts)
            },
            
            showAll(key){
                this[key]=!this[key]
            },

            filterChange(type,value,index){
                // this.clearFacetFilter(type)
                if(type==='facetYear'){
                    if(this.facetYearFilterList.indexOf(value)==-1) {
                        this.facetYearFilterList.push(value)
                        this.facetYear = ""
                        this.facetYearFilterList.forEach(element => {
                            this.facetYear += element + ' '
                        });
                        this.addFilter(type,'出版年',value)
                    }
                }
                if(type==='facetPlace'){
                    if(this.facetPlaceFilterList.indexOf(value)==-1) {
                        this.facetPlaceFilterList.push(value)
                        this.facetPlace = ""
                        this.facetPlaceFilterList.forEach(element => {
                            this.facetPlace += element + ' '
                        });
                        this.addFilter(type,'出版地',value)
                    }
                }
                if(type==='facetPublisher'){
                    if(this.facetPublisherFilterList.indexOf(value)==-1) {
                        this.facetPublisherFilterList.push(value)
                        this.facetPublisher = ""
                        this.facetPublisherFilterList.forEach(element => {
                            this.facetPublisher += element + ' '
                        });
                        this.addFilter(type,'出版社',value)
                    }
                }
                if(type==='facetClass'){
                    if(this.facetClassFilterList.indexOf(value)==-1) {
                        this.facetClassFilterList.push(value)
                        this.facetClass = ""
                        this.facetClassFilterList.forEach(element => {
                            this.facetClass += element + ' '
                        });
                        this.addFilter(type,'图书分类',value)
                    }
                }
                if(type==='facetPerson'){
                    if(this.facetPersonFilterList.indexOf(value)==-1) {
                        this.facetPersonFilterList.push(value)
                        this.facetPerson = ""
                        this.facetPersonFilterList.forEach(element => {
                            this.facetPerson += element + ' '
                        });
                        this.addFilter(type,'作者',value)
                    }
                }
                if(type==='facetKeyword'){
                    if(this.facetKeywordFilterList.indexOf(value)==-1) {
                        this.facetKeywordFilterList.push(value)
                        this.facetKeyword = ""
                        this.facetKeywordFilterList.forEach(element => {
                            this.facetKeyword += element + ' '
                        });
                        this.addFilter(type,'主题词',value)
                    }
                }
                if(type==='facetPdfCount'){
                    if(this.facetPdfCountFilterList.indexOf(value)==-1) {
                        this.facetPdfCountFilterList.push(value)
                        this.facetPdfCount = ""
                        this.facetPdfCountFilterList.forEach(element => {
                            this.facetPdfCount += element + ' '
                        });
                        this.addFilter(type,'是否有全文',value == "1" ? "内网有":value == "0" ? "外网有":"无")
                    }
                }
                this.sortScore = '1'
                this.sortTitle = ''
                this.sortPerson = ''
                this.pageth = 1
                this.pageSize = 10
                this.normalSearch()

                // 检索埋点（按钮检索） START
                this.query = ""
                this.filterQueries = []
                this.actionType = "聚类检索"
                if(this.params.all) {
                    this.query += "AND ALL:'"+this.params.all+"' "
                }
                if(this.params.title) {
                    this.query += "AND TM:'"+this.params.title+"' "
                }
                if(this.params.person) {
                    this.query += "AND ZRZ:'"+this.params.person+"' "
                }
                if(this.params.place) {
                    this.query += "AND CBD:'"+this.params.place+"' "
                }
                if(this.params.publisher) {
                    this.query += "AND CBJG:'"+this.params.publisher+"' "
                }
                if(this.params.theme) {
                    this.query += "AND ZTC:'"+this.params.theme+"' "
                }
                if(this.params.publication) {
                    this.query += "AND FXJG:'"+this.params.publication+"' "
                }
                if(this.params.start) {
                    this.query += "AND YEAR:['"+this.params.start+"' TO *] "
                }
                if(this.params.end) {
                    this.query += "AND YEAR:[* TO '"+this.params.freetext+"'] "
                }
                // 分面
                if(this.facetYear&&this.facetYear=='其他 ') {
                    this.query += "NOT FACET_YEAR='"+this.facetYear+"' "
                }
                if(this.facetYear&&this.facetYear!='其他 ') {
                    this.query += "AND FACET_YEAR='"+this.facetYear+"' "
                }
                if(this.facetPlace&&this.facetPlace=='其他 ') {
                    this.query += "NOT FACET_PLACE='"+this.facetPlace+"' "
                }
                if(this.facetPlace&&this.facetPlace!='其他 ') {
                    this.query += "AND FACET_PLACE='"+this.facetPlace+"' "
                }
                if(this.facetPublisher&&this.facetPublisher=='其他 ') {
                    this.query += "NOT FACET_PUBLISHER='"+this.facetPublisher+"' "
                }
                if(this.facetPublisher&&this.facetPublisher!='其他 ') {
                    this.query += "AND FACET_PUBLISHER='"+this.facetPublisher+"' "
                }
                if(this.facetClass&&this.facetClass=='其他 ') {
                    this.query += "NOT FACET_CLASSES='"+this.facetClass+"' "
                }
                if(this.facetClass&&this.facetClass!='其他 ') {
                    this.query += "AND FACET_CLASSES='"+this.facetClass+"' "
                }
                if(this.facetPerson&&this.facetPerson=='其他 ') {
                    this.query += "NOT FACET_PERSON='"+this.facetPerson+"' "
                }
                if(this.facetPerson&&this.facetPerson!='其他 ') {
                    this.query += "AND FACET_PERSON='"+this.facetPerson+"' "
                }
                if(this.facetKeyword&&this.facetKeyword=='其他 ') {
                    this.query += "NOT FACET_SUBJECT='"+this.facetKeyword+"' "
                }
                if(this.facetKeyword&&this.facetKeyword!='其他 ') {
                    this.query += "AND FACET_SUBJECT='"+this.facetKeyword+"' "
                }
                if(this.facetPdfCount&&this.facetPdfCount=='其他 ') {
                    this.query += "NOT FACET_ACCESSLEVEL='"+this.facetPdfCount+"' "
                }
                if(this.facetPdfCount&&this.facetPdfCount!='其他 ') {
                    this.query += "AND FACET_ACCESSLEVEL='"+this.facetPdfCount+"' "
                }
                // this.buryingPoint()
                // 检索埋点（按钮检索） END
            },

            addParamsFilter(params) {
                // 先清空params
                this.clearParamsFilter()
                if(params.all) {
                    this.addFilter('all','全字段',params.all)
                }
                if(params.title) {
                    this.addFilter('title','题名',params.title)
                }
                if(params.person) {
                    this.addFilter('person','作者',params.person)
                }
                if(params.place) {
                    this.addFilter('place','出版地',params.place)
                }
                if(params.publisher) {
                    this.addFilter('publisher','出版社',params.publisher)
                }
                if(params.theme) {
                    this.addFilter('theme','主题词',params.theme)
                }
                if(params.publication) {
                    this.addFilter('publication','发行制作机构',params.publication)
                }
                if(params.start) {
                    this.addFilter('start','起始年',params.start)
                }
                if(params.end) {
                    this.addFilter('end','结束年',params.end)
                }
            },

            addFilter(type,title,value){
                if(value) {
                    this.filters.push({type,title,value})
                }
            },


            clearParamsFilter() {
                this.typeList.forEach(element => {
                    for (let i = 0; i < this.filters.length; i++) {
                        if(this.filters[i].type==element) {
                            this.filters.splice(i,1)
                        }
                    }
                })
            },

            clearFacetFilter(type) {
                for (let i = 0; i < this.filters.length; i++) {
                    if(this.filters[i].type==type) {
                        this.filters.splice(i,1)
                    }
                }
            },

            onChange(pageth, size) {
                this.pageth = pageth
                this.pageSize = size
                this.normalSearch()
            },

            onShowSizeChange(current, size) {
                this.pageSize = size
                this.normalSearch()
            },

            secondSearch() {
                this.checkKeywords()
                this.normalSearch()

                // 检索埋点（按钮检索） START
                this.query = ""
                this.filterQueries = []
                this.actionType = "按钮检索"
                if(this.params.all) {
                    this.query += "AND ALL:'"+this.params.all+"' "
                }
                if(this.params.title) {
                    this.query += "AND TM:'"+this.params.title+"' "
                }
                if(this.params.person) {
                    this.query += "AND ZRZ:'"+this.params.person+"' "
                }
                if(this.params.place) {
                    this.query += "AND CBD:'"+this.params.place+"' "
                }
                if(this.params.publisher) {
                    this.query += "AND CBJG:'"+this.params.publisher+"' "
                }
                if(this.params.theme) {
                    this.query += "AND ZTC:'"+this.params.theme+"' "
                }
                if(this.params.publication) {
                    this.query += "AND FXJG:'"+this.params.publication+"' "
                }
                if(this.params.start) {
                    this.query += "AND YEAR:['"+this.params.start+"' TO *] "
                }
                if(this.params.end) {
                    this.query += "AND YEAR:[* TO '"+this.params.freetext+"'] "
                }
                // 分面
                if(this.facetYear&&this.facetYear=='其他 ') {
                    this.query += "NOT FACET_YEAR='"+this.facetYear+"' "
                }
                if(this.facetYear&&this.facetYear!='其他 ') {
                    this.query += "AND FACET_YEAR='"+this.facetYear+"' "
                }
                if(this.facetPlace&&this.facetPlace=='其他 ') {
                    this.query += "NOT FACET_PLACE='"+this.facetPlace+"' "
                }
                if(this.facetPlace&&this.facetPlace!='其他 ') {
                    this.query += "AND FACET_PLACE='"+this.facetPlace+"' "
                }
                if(this.facetPublisher&&this.facetPublisher=='其他 ') {
                    this.query += "NOT FACET_PUBLISHER='"+this.facetPublisher+"' "
                }
                if(this.facetPublisher&&this.facetPublisher!='其他 ') {
                    this.query += "AND FACET_PUBLISHER='"+this.facetPublisher+"' "
                }
                if(this.facetClass&&this.facetClass=='其他 ') {
                    this.query += "NOT FACET_CLASSES='"+this.facetClass+"' "
                }
                if(this.facetClass&&this.facetClass!='其他 ') {
                    this.query += "AND FACET_CLASSES='"+this.facetClass+"' "
                }
                if(this.facetPerson&&this.facetPerson=='其他 ') {
                    this.query += "NOT FACET_PERSON='"+this.facetPerson+"' "
                }
                if(this.facetPerson&&this.facetPerson!='其他 ') {
                    this.query += "AND FACET_PERSON='"+this.facetPerson+"' "
                }
                if(this.facetKeyword&&this.facetKeyword=='其他 ') {
                    this.query += "NOT FACET_SUBJECT='"+this.facetKeyword+"' "
                }
                if(this.facetKeyword&&this.facetKeyword!='其他 ') {
                    this.query += "AND FACET_SUBJECT='"+this.facetKeyword+"' "
                }
                if(this.facetPdfCount&&this.facetPdfCount=='其他 ') {
                    this.query += "NOT FACET_ACCESSLEVEL='"+this.facetPdfCount+"' "
                }
                if(this.facetPdfCount&&this.facetPdfCount!='其他 ') {
                    this.query += "AND FACET_ACCESSLEVEL='"+this.facetPdfCount+"' "
                }
                this.filterQueries = [this.secondCdtn]
                // this.buryingPoint()
                // 检索埋点（按钮检索） END
            },

            async getResultData(opts) {
                // await axios.post("api/instance/search", opts).then(response => {
                await axios.post(instanceSearch, opts).then(response => { // chenss 20240327
                    if (response.data.success) {
                        this.resultData = response.data.data.resultList
                        this.rowCount = response.data.data.pager.rowCount
                        this.facetYearList = response.data.data.facetList[0].year
                        this.facetPlaceList = response.data.data.facetList[1].place
                        this.facetPublisherList = response.data.data.facetList[2].publisher
                        this.facetClassList = response.data.data.facetList[4].classes
                        this.facetPersonList = response.data.data.facetList[3].person
                        this.facetKeywordList = response.data.data.facetList[5].subject
                        this.facetPdfCountList = response.data.data.facetList[6].accessLevel
                        this.spinning = false
                    } else {
                        this.$message.error("System Error")
                    }
                });
            },

            // 检索埋点
            async buryingPoint() {
                await axios.post(reportQuery, {
                    pieceTypeId: 1,
                    products: [],
                    facets: [],
                    token: sessionStorage.getItem('token'),
                    query: this.query,
                    filterQueries: this.filterQueries,
                    actionType: this.actionType,
                    sourceType: "高级检索",
                    searchType: "FUZZY",
                }).then(response => {
                    if (response.data.status==0) {
                        // 成功
                    } else {
                        // 失败
                    }
                });
            },

            async checkUser() {
                this.$parent.$parent.spinner = true
                /* 
                判断是否有传入token
                登录：https://www.cnbksy.com/jdLogin?targetUrl=https://tushu.cnbksy.com?ss
                返回token：https://jdts.library.sh.cn/?ss&token=6fd70427739110ab86b4a2f427423bb2e0c1cc2707665536f676fb4dda7a7ff6af8503d1c564ea39f86392a3848ec58ee7590403f3aee5947c0f9838e5f61396#/
                router(路由配置) 需修改为 mode: 'history' 模式
                通过 this.$route.query.xxx 获取
                */
                if(!sessionStorage.getItem('token')) {
                    sessionStorage.setItem('token', this.$route.query.token||'')
                }
                if(sessionStorage.getItem('token')&&!sessionStorage.getItem('orgName')) {
                    await axios.post(accountAuthtication, {params: {token: sessionStorage.getItem('token')}}).then(response => {
                        if (response.data.result==0) {
                            this.$parent.$parent.$refs.header.orgName = response.data.data.username
                            sessionStorage.setItem('orgName', response.data.data.username)
                            this.$router.push({name: 'advanceSearch'})
                        } else {
                            this.visibleUser = true
                        }
                    });
                }
                if(sessionStorage.getItem('token')) {
                    this.$router.push({name: 'advanceSearch'})
                }
                this.$parent.$parent.spinner = false
            },
            ConfirmError(){
                this.visibleUser = false
            },
            login() {
                window.location = 'https://dhapi.library.sh.cn/management/webapi/cenofmagent/token/locpage?systemId=20&durl=https://jdts.library.sh.cn/index'
            },

            async logout() {
                this.$parent.$parent.spinner = true
                this.visibleLook = false
                sessionStorage.setItem('token', '')
                sessionStorage.setItem('orgName', '')
                this.$router.push({
                    name: 'advanceSearch'
                })
                location.reload()
            },

            quit() {
                window.opener = null;
                window.open("about:blank", "_self").close()
            },

        }
    }
</script>

<style lang="less" scoped>
    .ant-btn-primary {
        background-color: #661112;
        border-color: #661112;
    }
    .filter-box {
        li {
            font-size: 1.1rem;
        }
        a {
            font-size: 1.1rem;
        }
    }
</style>